$(function(){	
	//轮播图
	var cur=0;
	var $img=$("img");
	$img.eq(0).fadeIn();
	function lunbo(){
		$img.eq(cur).fadeIn(500).siblings().hide();
		cur++;
		cur = cur >= $img.length ? 0:cur;
		auto=setTimeout(lunbo,4000);
	}
	lunbo();
	//验证用户名或密码不能为空
	$("#logintrue").click(function(){
		var verificatio1=verification($("#loginName").val(),$("#loginPwd").val());
		if(verificatio1){
			$.ajax({
				url: "/shiro/login?userName="+$("#loginName").val()+"&passWord="+$("#loginPwd").val(),
				type: "post",
				dataType: "json",
				data:{},
				success: function(data){
					if(data.code==1){
						alert("登陆成功");
						location.href="/toPath?path=web/index.html";
					}else if(data.code==2){
						alert(data.message);
					}else if(data.code==3){
						alert(data.obj);
					}
				},
				error: function(msg){
					alert("ajax连接异常："+msg);
				}
			});
		}else{
			alert("用户名或密码不能为空");
		}
	})
	//判断登录的用户名是否为空
	function verification(name,pwd){
		if(name=='' || pwd==''){
			return false;
		}else{
			return true;
		}
	}
})
	var pwd=0;
	var name=0;
	var eye = document.getElementById("eye");
    var pwd = document.getElementById("loginPwd");
    var pwd = document.getElementById("loginPwd");

    function showhide(){

            if (pwd.type == "password") {
                pwd.type = "text";
                    eye.className='fa fa-eye-slash'
            }else {
                pwd.type = "password";
                eye.className='fa fa-eye'
            }
    }
    
	function sign(){
		var name=$("#signName").val();
		var pwd=$("#signPwd").val();
		var realName=$("#signRealName").val();
		if(name==''||pwd==''||realName==''){
			alert("请填写完成在注册")
		}else{
			//注册
			$.ajax({
				url: "/shiro/sign",
				type: "post",
				dataType: "json",
				data:$("#signForm").serializeArray(),
				success: function(data){
					alert(data.message);
					location.reload();
				},
				error: function(msg){
					alert("ajax连接异常："+msg);
				}
			});
		}
	}
	function PasswordComparison(){
		if($("#signPwd").val()==$("#signPwd1").val()){
			pwd=1;
			if(name==1){
				$("#signButton").attr("disabled",false);
			}
			$("#signPwdPanDuan").html(" ")			
		}else{
			$("#signPwdPanDuan").html("两次密码不一致")
			$("#signButton").attr("disabled",true);
			pwd=0;
		}
	}
	function signNameComparison(){
		$.ajax({
			url: "/shiro/signNameComparison?userName="+$("#signName").val(),
			type: "post",
			dataType: "json",
			data:{},
			success: function(data){
				if(data.code==1){
					name=1;
					if(pwd==1){
						$("#signButton").attr("disabled",false);
					}
					$("#signNamePanDuan").html(" ")
				}else {
					name=0;
					$("#signNamePanDuan").html("用户已存在")
					$("#signButton").attr("disabled",true);
				}
			},
			error: function(msg){
				alert("ajax连接异常："+msg);
			}
		});
	}

	function tologin(){
		location.href="/"
	}